<html>
<head>
    <#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
    <#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
    <!-- bootstrap-datetimepicker -->
    <link href="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/css/form.lzy.css" rel="stylesheet">
</head>
<body>
        <div class="panel panel-f5">
            <div class="panel-body">
                 <form id="myForm" class="form-inline">
                      <div class="form-group">  
                        <span>品牌名称：</span>
                        <input type="text" class="form-control" id="name">  
                          <button type="button" class="btn btn-primary btn-sm" onclick="search(1)">查询</button>
                          <button type="button" class="btn btn-primary btn-sm" onclick="$('#myForm')[0].reset();">重置</button>
                      </div>
                 </form>  
            </div>
              <!-- 分页查询的地址-->
            <div class="panel-body panel-white">
                <div class="table-responsive">
                    <table id="myTable"
                           class="table table-hover"
                           data-url="${basePath}/merchant/json"
                           data-pageSize="10,50,100" data-method="GET">
                        <thead>
                          <!-- 需要循环的字段  对应mapper文件-->
                        <tr>
                            <th data-type="xuhao" >序号</th>
                            <th data-field="name">品牌名称</th> 
                            <th data-field="button" data-call="true">操作</th>
                        </tr>
                        </thead>
                        <tbody id="tbodyId">
                        </tbody>
                    </table>
                </div>
                  <!-- 分页条-->
                <div class="row">
                     <div align="left" class="col-xs-12" style="display:none;">
                        <div class="input-group">
                            <span class="input-group-addon" id="pageCount"></span> <select
                                id="pageSize" onchange="search(1)" class="form-control"
                                style="width: 100px"></select>
                        </div>
                    </div> 
                    <div align="right" class="col-xs-12">
                        <ul class="pagination" id="pagination"></ul>
                    </div>
                </div>
            </div>
        </div>

<#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
<script type="text/javascript" src="${basePath}/bootstrap/js/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/myPage.js"></script>
<!-- bootstrap-datetimepicker -->
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">

//循环列表数据以及操作按钮
function tableCallBack(data, id){
	 if(id == 'button') {//增加操作按钮
        var _button = '';
            _button += '<button type="button" class="btn btn-white btn-xs" onclick="addBrand('+ data.id +',\'' + data.name + '\');">添加 </button> ';
        return _button;
    } else {
        if(data[id] == null || data[id] == ''){
            return '';
        }else{
            return data[id];
        }
    }
}


//新增
 function addBrand(id,str){
	//给父页面传值
	var arrBrand=parent.$('#brandId').val().split(",");
	var strId = id.toString();
	var indexArr = arrBrand.indexOf(strId);
     if(indexArr==-1){
    	 var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
 	    var pId = "";
 	    var strSpan ='<span id="'+id+'" class="brand-littlebox">'+str+' <i class="fa fa-times text-danger" title="移除" onclick="removeBrand(this)"></i></span>';
 	    	 if(parent.$('#brandId').val()==""){
 	 		    	pId = id;
 	 		    }else{
 	 		    	pId = parent.$('#brandId').val()+","+id; 
 	 		    }
 	    	    parent.$('#brandDivParent').show();
 	 		    parent.$('#brandDiv').append(strSpan);
 	 			parent.$('#brandId').val(pId).change();
 	 			parent.layer.close(index);  
     }else{
    	 layer.alert('该品牌已添加！');
     }
 }
</script>
</body>
</html>